<template>
  <weighbill-designer
    :widget-options="widgetOptions"
    :temp-value="tempValue"
    @save="saveTemp"
    @preview="previewTemp"
  ></weighbill-designer>
</template>

<script>
export default {
  name: "App",
  components: {},
  props: {
    tempValue: {
      type: Object,
      default: () => ({
        title: "demo",
        width: 750,
        height: 550,
        pageWidth: 750,
        pageHeight: 550,
        tempItems: [],
      }),
    },
  },
  emits: ["save", "preview"],
  data() {
    return {
      // 设计器实例
      widgetOptions: [
        {
          type: "braid-txt",
          isEdit: 1,
          title: "自定义文本",
          value: "自定义文本",
          defaultValue: "自定义文本",
          name: "",
        },
        {
          type: "braid-txt",
          isEdit: 0,
          title: "公司名称",
          value: "{公司名称}",
          defaultValue: "某某公司",
          name: "companyName",
        },
      ],
    };
  },
  methods: {
    saveTemp() {
      console.log("保存模板", temp);
    },
    previewTemp() {
      console.log("预览模板", temp);
    },
  },
};
</script>
